package com.kernel.net;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/****************************************
 * @name HelloServer
 * @description
 * @author 黄彬恒
 * @since 2018/8/24
 ***************************************/
public class EchoServer {
    public static void main(String[] args) throws IOException {
        ServerSocket server;
        Socket client;
        server = new ServerSocket(8888); // 服务在8888端口上监听
        boolean flag = true;
        while (flag) {
            System.out.println("服务器运行，等待客户端连接...");
            client = server.accept();// 得到连接，程序进入到阻塞状态
            new Thread(new EchoThread(client)).start();
        }
        server.close();
    }
}
